package mo.offer_version2;

public class L56_1 {

    public int[] singleNumbers(int[] nums) {
        int res = 0;
        for (int num : nums) {
            res = res ^ num;
        }
        int m = 1;
        while ((m & res) == 0) {
            m = m << 1;
        }
        int a = 0;
        int b = 0;
        for (int num : nums) {
            if ((num & m) != 0) {
                a = a ^ num;
            } else {
                b = b ^ num;
            }
        }
        return new int[]{a, b};
    }

}
